package cn.mythreadtest.test3;

public class MyRunnable implements Runnable {
    int number = 0;
    @Override
    public void run() {
        while (true){
            synchronized (MyRunnable.class){
                if(number>100){
                    break;
                }else{
                    try {
                        Thread.sleep(50);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    if (number%2==1){
                        System.out.println(Thread.currentThread().getName() + "打印数字" + number);
                    }
                    number++;
                }
            }
        }
    }
}
